package com.cn.util;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;

@Component
public class ThreadUtil {
    @Async("asyncExecutor")
    public CompletableFuture<Integer> dealNum(Integer n) {
        try {
            Thread.sleep(1000);
            n = n * 2;
        } catch (InterruptedException e) {
            n = 0;
        }
        return CompletableFuture.completedFuture(n);
    }
}
